// 云函数入口文件
const cloud = require('wx-server-sdk')

var md5 = require('md5');


cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
})


// 云函数入口函数
exports.main = async (event, context) => {
    const ctx = cloud.getWXContext()
    console.log(
        'cloud.DYNAMIC_CURRENT_ENV',
        cloud.DYNAMIC_CURRENT_ENV
    )
    const {
        list,
    } = event

    const db = cloud.database({

    })
    let res = await db.collection('user_subscribe').doc(ctx.OPENID).set({
        data: {
            list,
            updateTime: +new Date()
        }
    })
    return res
    //console.log('同步成功');
}